import { LogHandle } from "@/type/logHandle";
import { LazyTableService, BaseAuthApi } from "@/hooks/useLazyLable";
import axios, { CancelToken, Response, authGuard } from "./axios";
import factorySingleClass from "./SingleClass";

interface LogHandleService extends BaseAuthApi {
    LOGINEXPORT: string;
}

let cancel: any;
class LogHandleService extends LazyTableService {
    @authGuard
    getList(query: string) {
        cancel && cancel();
        return axios.get<Response<LogHandle[]>>(
            `/mediaslib-service/log/operate?${query}`,
            {
                cancelToken: new CancelToken((c) => (cancel = c)),
            },
        );
    }
    @authGuard
    loginExport(query: string, option: any = {}) {
        return axios.get(
            `/mediaslib-service/log/operateExport?${query}`,
            option,
        );
    }
}

export default factorySingleClass(LogHandleService);
